<template>
  <div class="user-con">
    <div class="w">
      <!-- 用户信息和用户登入注册 -->
      <div class="user-top">
        <img src="imgs/icon/user.png" alt="">
        <span v-if="username">
          <a>{{username}}</a>
        </span>
        <span v-else>
          <router-link to="/login">登入 / </router-link>
          <router-link to="/login">注册</router-link>
        </span>
      </div>
      <!-- 我的订单 -->
      <div class="order">
        <span>我的订单</span>
        <div class="goOrder">
          <router-link to="/order">全部订单</router-link>
          <img src="imgs/icon-right.png" alt="">
        </div>
      </div>
      <!-- 订单状态 -->
      <div class="order-status">
        <div class="status-item" @click="$router.push('/order')">
          <img src="imgs/money.png" alt="">
          <p>未支付</p>
          <NumBer :numBer="needPayOrder.length" v-show="needPayOrder.length>0"></NumBer>
        </div>
        <div class="status-item" @click="$router.push('/order')">
          <img src="imgs/car.png" alt="">
          <p>未收货</p>
          <NumBer :numBer="okOrder.length" v-show="okOrder.length>0"></NumBer>
        </div>
        <div class="status-item">
          <img src="imgs/uilt.png" alt="">
          <p>退换修</p>
        </div>
      </div>
      <div class="line"></div>
      <SpaCom>
        <template #icon>
          <img src="imgs/icon-header.png" alt="" class="icon-box">
        </template>
        <template #name>
          <span>会员中心</span>
        </template>
      </SpaCom>
      <SpaCom>
        <template #icon>
          <img src="imgs/dianjuan.png" alt="" class="icon-box">
        </template>
        <template #name>
          <span>领卷中心</span>
        </template>
      </SpaCom>
      <SpaCom>
        <template #icon>
          <img src="imgs/hart.png" alt="" class="icon-box">
        </template>
        <template #name>
          <span>服务中心</span>
        </template>
      </SpaCom>
      <SpaCom>
        <template #icon>
          <img src="imgs/config.png" alt="" class="icon-box">
        </template>
        <template #name>
          <span @click="$router.push('/config')">设置</span>
        </template>
      </SpaCom>
    </div>
  </div>
</template>

<script>
import { mapState, mapGetters } from 'vuex'
export default {
  // eslint-disable-next-line vue/multi-word-component-names
  name: 'User',
  computed: {
    ...mapState(['username']),
    ...mapGetters(['needPayOrder', 'okOrder'])
  }
}
</script>

<style lang="less" scoped>
.w {
  width: 720px;
  margin: 0 auto;
}
.user-con {
  font-size: 28px;
  img {
    vertical-align: middle;
  }
  .user-top {
    height: 160px;
    padding: 32px 0 32px 32px;
    background-color: #f37d0f;
    img {
      width: 91px;
      height: 91px;
      margin-right: 20px;
    }
    a {
      color: #fff;
    }
  }
  .order {
    display: flex;
    justify-content: space-between;
    padding: 0 52px;
    height: 100px;
    line-height: 100px;
    border-bottom: 1px solid #ccc;
    img {
      width: 40px;
      height: 40px;
    }
  }
  .order-status {
    display: flex;
    justify-content: space-between;
    align-items: center;
    height: 170px;
    padding: 0 80px;
    img {
      width: 48px;
      height: 48px;
    }
    .status-item {
      position: relative;
      text-align: center;
    }
  }
}
</style>
